Enabling SSL on a virtual host

Enabling SSL on a virtual host

am 15.12.2009 16:48:15 von Jonathan Mast

--000e0cd11ae071d429047ac65161
Content-Type: text/plain; charset=ISO-8859-1

I have a single webserver (1 IP) to which many DNS entries point to. Up
till now I've haven't needed SSL and the following config pattern has worked
fine for me:


ServerName foo.mysite.com
....



ServerName bar.mysite.com
....



However, when I added SSL to to foo.mysite.com, the config had to become:

....SSLStuff

In the meantime non-HTTPS traffic to foo.mysite.com worked fine except that
the Alias directives did not work. So I realized the problem (the port was
only for 443) and changed the config to:


But this has the unwanted effect of returning 400 Bad Request to HTTP
traffic for foo.mysite.com, with this message:
Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

So my question is, how do I configure the VirtualHost to allow HTTP traffic
(port 80) and HTTPS traffic (443)?

--000e0cd11ae071d429047ac65161
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I have a single webserver (1 IP) to which many DNS entries point to.=A0 Up =
till now I've haven't needed SSL and the following config pattern h=
as worked fine for me:

<VirtualHost *>
ServerName =3D"http://foo.mysite.com">foo.mysite.com

....
</VirtualHost>

<VirtualHost *>
ServerName ref=3D"http://bar.mysite.com">bar.mysite.com
...
</VirtualHost=
>


However, when I added SSL to to e.com">foo.mysite.com, the config had to become:

<VirtualHost foo.mysite.com:443 >>
...SSLStuff

In the meantime non-HTTPS traffic to
"http://foo.mysite.com">foo.mysite.com worked fine except that the Alia=
s directives did not work.=A0 So I realized the problem (the port was only =
for 443) and changed the config to:

<VirtualHost =
>

But=
this has the unwanted effect of returning 400 Bad Request to HTTP traffic =
for , with this message=
:

Your browser sent a request that this server could not understand.

Reason: You're speaking plain HTTP to an SSL-enabled server port.

Instead use the HTTPS scheme to access this URL, please.

So my quest=
ion is, how do I configure the VirtualHost to allow HTTP traffic (port 80) =
and HTTPS traffic (443)?


--000e0cd11ae071d429047ac65161--

Re: Enabling SSL on a virtual host

am 15.12.2009 16:53:26 von Eric Covener

On Tue, Dec 15, 2009 at 10:48 AM, Jonathan Mast
wrote:
> So my question is, how do I configure the VirtualHost to allow HTTP traffic
> (port 80) and HTTPS traffic (443)?

You need two virtualhosts, one with SSL and one without. If you want
everything other than SSL to be common, use Include to source a common
config.

I'd suggest *:80 and *:443 until you have to actually discriminate
based on the local IP address. If you need to discriminate based on
hostname requested for non-SSL, add NameVirtualHost *:80.

--
Eric Covener
covener@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Enabling SSL on a virtual host

am 15.12.2009 17:37:23 von Jonathan Mast

--000e0cd1a8cc2a5228047ac70141
Content-Type: text/plain; charset=ISO-8859-1

I'm thinking that the host name actually is required in the VirtualHost
declaration.

But the 2 separate VirtualHost entries worked, thanks

On Tue, Dec 15, 2009 at 10:53 AM, Eric Covener wrote:

> On Tue, Dec 15, 2009 at 10:48 AM, Jonathan Mast
> wrote:
> > So my question is, how do I configure the VirtualHost to allow HTTP
> traffic
> > (port 80) and HTTPS traffic (443)?
>
> You need two virtualhosts, one with SSL and one without. If you want
> everything other than SSL to be common, use Include to source a common
> config.
>
> I'd suggest *:80 and *:443 until you have to actually discriminate
> based on the local IP address. If you need to discriminate based on
> hostname requested for non-SSL, add NameVirtualHost *:80.
>
> --
> Eric Covener
> covener@gmail.com
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

--000e0cd1a8cc2a5228047ac70141
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I'm thinking that the host name actually is required in the VirtualHost=
declaration.

But the 2 separate VirtualHost entries worked, thanks=


On Tue, Dec 15, 2009 at 10:53 AM, Eric C=
ovener <covener@g=
mail.com
>
wrote:

204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
>On Tue, Dec 15, 2009 at 10:48 AM, Jonathan Mast

<jhmast.developer@gmail.co=
m
> wrote:

> So my question is, how do I configure the VirtualHost to allow HTTP tr=
affic

> (port 80) and HTTPS traffic (443)?



You need two virtualhosts, one with SSL and one without. If you want<=
br>
everything other than SSL to be common, use Include to source a common

config.



I'd suggest *:80 and *:443 until you have to actually discriminate

based on the local IP address. If you need to discriminate based on

hostname requested for non-SSL, add NameVirtualHost *:80.



--

Eric Covener





------------------------------------------------------------ ---------

The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL: lank">http://httpd.apache.org/userslist.html> for more info.

To unsubscribe, e-mail: g">users-unsubscribe@httpd.apache.org

=A0 " =A0 from the digest: @httpd.apache.org">users-digest-unsubscribe@httpd.apache.org

For additional commands, e-mail: org">users-help@httpd.apache.org






--000e0cd1a8cc2a5228047ac70141--

Re: Enabling SSL on a virtual host

am 16.12.2009 13:17:43 von Krist van Besien

On Tue, Dec 15, 2009 at 5:37 PM, Jonathan Mast
wrote:
> I'm thinking that the host name actually is required in the VirtualHost

No it is not required.

A hostname in a VirtualHost directive is internally converted to an IP
address and only needed if this VirtualHost needs to be bound to a
particular IP on a multi homed host. In most practical scenarios
having *:443 and *:80 in your VirtuaHost direcives is perfectly
adequate.

Krist

--
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Enabling SSL on a virtual host

am 16.12.2009 13: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